package cn.wh.mybatis.session.defaults;

import cn.wh.mybatis.binding.MapperRegistry;
import cn.wh.mybatis.session.SqlSession;

/**
 * @Description 默认sqlSession
 * @Version 1.0.0
 * @Date 2022/11/29 16:20
 * @Created wh
 */
public class DefaultSqlSession implements SqlSession {


    private MapperRegistry mapperRegistry;

    public DefaultSqlSession(MapperRegistry mapperRegistry) {
        this.mapperRegistry = mapperRegistry;
    }

    @Override
    public <T> T selectOne(String statement) {
        return (T)("你被代理了"+statement);
    }

    @Override
    public <T> T selectOne(String statement, Object parameter) {
        return (T)("你被代理了!"+"方法:"+statement+"入参:"+parameter);
    }

    @Override
    public <T> T getMapper(Class<T> type) {
        return mapperRegistry.getMapper(type,this);
    }
}
